package ace.module.stock.core.impl.api.impl;

import ace.cmp.core.model.R;
import ace.module.common.api.annotation.ApiLocalPriority;
import ace.module.common.api.model.input.TenantAndAppTypeInput;
import ace.module.common.core.impl.api.impl.SdkApiImpl;
import ace.module.stock.api.WmsStockApi;
import ace.module.stock.api.model.dto.WmsStockDto;
import ace.module.stock.api.model.dto.ext.WmsStockDetailDto;
import ace.module.stock.api.model.input.WmsBizInitInput;
import ace.module.stock.api.model.input.WmsStockActionRecordWithBatchSnInput;
import ace.module.stock.api.model.input.WmsStockActionTypeRecordWithBatchSnInput;
import ace.module.stock.api.model.input.WmsStockReverseBatchSnInput;
import ace.module.stock.core.impl.dao.entity.WmsStock;
import ace.module.stock.core.impl.manager.WmsStockManager;
import ace.module.stock.core.impl.service.WmsStockService;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;


/**
 * 库存 api implements.
 *
 * @author Caspar
 *
 */
@ApiLocalPriority
@AllArgsConstructor
@Component
public class WmsStockApiImpl
    extends SdkApiImpl<WmsStock, Long, WmsStockDto, WmsStockManager>
    implements WmsStockApi {

  private final WmsStockService wmsStockService;

  @Override
  public R<WmsStockDetailDto> initOrSet(TenantAndAppTypeInput<WmsBizInitInput> input) {
    WmsStockDetailDto result = wmsStockService.initOrSet(input);
    return R.ok(result);
  }

  @Override
  public R<String> modify(TenantAndAppTypeInput<WmsStockActionTypeRecordWithBatchSnInput> input) {
    String sn = wmsStockService.modify(input);
    return R.ok(sn);
  }

  @Override
  public R<String> add(TenantAndAppTypeInput<WmsStockActionRecordWithBatchSnInput> input) {
    String result = wmsStockService.add(input);
    return R.ok(result);
  }

  @Override
  public R<String> subtract(TenantAndAppTypeInput<WmsStockActionRecordWithBatchSnInput> input) {
    String result = wmsStockService.subtract(input);
    return R.ok(result);
  }

  @Override
  public R<String> reverse(TenantAndAppTypeInput<WmsStockReverseBatchSnInput> input) {
    String result = wmsStockService.reverse(input);
    return R.ok(result);
  }


  @Override
  public R<List<WmsStockDto>> getSkuByObjectIdIn(TenantAndAppTypeInput<List<Long>> skuIdInput) {
    List<WmsStockDto> result = wmsStockService.getSkuByObjectIdIn(skuIdInput);
    return R.ok(result);
  }

  @Override
  public R<List<WmsStockDto>> getProductByObjectIdIn(TenantAndAppTypeInput<List<Long>> productIdInput) {
    List<WmsStockDto> result = wmsStockService.getProductByObjectIdIn(productIdInput);
    return R.ok(result);
  }
}
